package com.bytedance.scenedemo;

import com.bytedance.scene.group.UserVisibleHintGroupScene;
import com.bytedance.scene.ktx.SceneExtensions;
import com.bytedance.scenedemo.navigation.forresult.SceneResultScene_0;
import com.bytedance.scenedemo.navigation.popinterupt.PopInterruptScene;
import com.bytedance.scenedemo.navigation.popto.PopToScene;
import com.bytedance.scenedemo.navigation.push_clear_current.PushClearCurrentDemoScene;
import com.bytedance.scenedemo.navigation.push_pop.PushPopBasicUsageDemoScene;
import com.bytedance.scenedemo.navigation.push_singletop.PushSingleTopRootScene;
import com.bytedance.scenedemo.navigation.pushandclear.PushClearTaskScene;
import com.bytedance.scenedemo.navigation.remove.RemoveDemoScene;
import com.bytedance.scenedemo.navigation.reuse.ReuseDemoScene;
import com.bytedance.scenedemo.navigation.singletask.SingleTaskDemoScene;
import com.bytedance.scenedemo.navigation.template.DefaultScene;
import ohos.aafwk.content.Intent;
import ohos.agp.components.*;

/**
 * Created by JiangQi on 8/21/18.
 */
public class NavigationListDemo extends UserVisibleHintGroupScene implements Component.ClickedListener{
    @Override
    public ComponentContainer onCreateView(LayoutScatter layoutScatter, ComponentContainer container, Intent savedInstanceState) {
        Component layout=layoutScatter.parse(ResourceTable.Layout_fraction_navigation_list_demo,container,false);
        Text textHint= (Text) layout.findComponentById(ResourceTable.Id_text_navigation_list_hint);
        Button btnPushPop= (Button) layout.findComponentById(ResourceTable.Id_btn_navigation_list_goto_push_pop);
        Button btnPushSingleTop= (Button) layout.findComponentById(ResourceTable.Id_btn_navigation_push_single_top);
        Button btnPushSingleTask= (Button) layout.findComponentById(ResourceTable.Id_btn_navigation_push_single_task);
        Button btnPushAndClear= (Button) layout.findComponentById(ResourceTable.Id_btn_navigation_push_and_clear);
        Button btnPushClearCurrent= (Button) layout.findComponentById(ResourceTable.Id_btn_navigation_push_clear_current);
        Button btnDelayTimeRemove= (Button) layout.findComponentById(ResourceTable.Id_btn_navigation_delay_time_remove);
        Button btnPopTo= (Button) layout.findComponentById(ResourceTable.Id_btn_navigation_pop_to);
        Button btnInterceptPop= (Button) layout.findComponentById(ResourceTable.Id_btn_navigation_intercept_pop);
        Button btnOnSceneResult= (Button) layout.findComponentById(ResourceTable.Id_btn_navigation_on_scene_result);
        Button btnReuseScene= (Button) layout.findComponentById(ResourceTable.Id_btn_navigation_reuse_scene);
        Button btnAppcompatScene= (Button) layout.findComponentById(ResourceTable.Id_btn_navigation_appcompat_scene);

        textHint.setText(getClassName());
        btnPushPop.setClickedListener(this);
        btnPushSingleTop.setClickedListener(this);
        btnPushSingleTask.setClickedListener(this);
        btnPushAndClear.setClickedListener(this);
        btnPushClearCurrent.setClickedListener(this);
        btnDelayTimeRemove.setClickedListener(this);
        btnPopTo.setClickedListener(this);
        btnInterceptPop.setClickedListener(this);
        btnOnSceneResult.setClickedListener(this);
        btnReuseScene.setClickedListener(this);
        btnAppcompatScene.setClickedListener(this);

        return (ComponentContainer) layout;
    }

    @Override
    public void onClick(Component component) {
        switch (component.getId()){
            case ResourceTable.Id_btn_navigation_list_goto_push_pop:
                SceneExtensions.requireNavigationScene(this).push(PushPopBasicUsageDemoScene.class);
                break;
            case ResourceTable.Id_btn_navigation_push_single_top:
                SceneExtensions.requireNavigationScene(this).push(PushSingleTopRootScene.class);
                break;
            case ResourceTable.Id_btn_navigation_push_single_task:
                SceneExtensions.requireNavigationScene(this).push(SingleTaskDemoScene.class);
                break;
            case ResourceTable.Id_btn_navigation_push_and_clear:
                SceneExtensions.requireNavigationScene(this).push(PushClearTaskScene.class);
                break;
            case ResourceTable.Id_btn_navigation_push_clear_current:
                SceneExtensions.requireNavigationScene(this).push(PushClearCurrentDemoScene.class);
                break;
            case ResourceTable.Id_btn_navigation_delay_time_remove:
                SceneExtensions.requireNavigationScene(this).push(RemoveDemoScene.class);
                break;
            case ResourceTable.Id_btn_navigation_pop_to:
                SceneExtensions.requireNavigationScene(this).push(PopToScene.class);
                break;
            case ResourceTable.Id_btn_navigation_intercept_pop:
                SceneExtensions.requireNavigationScene(this).push(PopInterruptScene.class);
                break;
            case ResourceTable.Id_btn_navigation_on_scene_result:
                SceneExtensions.requireNavigationScene(this).push(SceneResultScene_0.class);
                break;
            case ResourceTable.Id_btn_navigation_reuse_scene:
                SceneExtensions.requireNavigationScene(this).push(ReuseDemoScene.class);
                break;
            case ResourceTable.Id_btn_navigation_appcompat_scene:
                SceneExtensions.requireNavigationScene(this).push(DefaultScene.class);
                break;
        }
    }
}
